<?php
/*
 * @Author: lokei
 * @Date: 2022-10-05 16:07:41
 * @LastEditors: lokei
 * @LastEditTime: 2023-11-20 19:15:24
 * @Description: 
 */
namespace App\Http\Controllers\Store\Contacts;

use App\Common\Tools\ResultTool;
use App\Http\Controllers\Controller;
use App\Models\Store\StoreModel;
use Illuminate\Http\Request;

class ContactsController extends Controller {
    public function getMobile(Request $request) {
        $store = StoreModel::where('id', '=', $request->input('store_id'))->first();
        $res = ResultTool::success();
        $res['data']['mobile'] = $store != null ? $store->contacts_mobile : '';
        return $res;
    }

    public function get(Request $request) {
        $store = StoreModel::where('id', '=', $request->input('store_id'))->first();
        $res = ResultTool::success();
        $res['data']['contacts_name'] = $store->contacts_name;
        $res['data']['contacts_mobile'] = $store->contacts_mobile;
        $res['data']['contacts_email'] = $store->contacts_email;
        $res['data']['contacts_qq'] = $store->contacts_qq;
        $res['data']['contacts_weixin'] = $store->contacts_weixin;
        $res['data']['official_site'] = $store->official_site;
        return $res;
    }

    public function set(Request $request) {
        $store = StoreModel::where('id', '=', $request->input('store_id'))->first();
        $store->contacts_name = $request->input('contacts_name');
        $store->contacts_mobile = $request->input('contacts_mobile');
        $store->contacts_email = $request->input('contacts_email');
        $store->contacts_qq = $request->input('contacts_qq');
        $store->contacts_weixin = $request->input('contacts_weixin');
        $store->official_site = $request->input('official_site');
        $store->save();
        return ResultTool::success();
    }
}